<template>
  <a-config-provider :locale="zhCN">
    <router-view v-slot="{ Component, route }">
      <keep-alive :include="cacheViewStore.cacheView">
        <component :is="Component" :key="route.name" />
      </keep-alive>
    </router-view>
  </a-config-provider>
</template>
<script lang="ts" setup>
import { watch } from "vue";
import { useStore as useUserStore } from "@/store/user";
import { $loginUser } from "@/api/login/login";
import zhCN from "ant-design-vue/es/locale/zh_CN";
import dayjs from 'dayjs';
import 'dayjs/locale/zh-cn';
import { useStore as useCacheViewStore } from "@/store/cacheView";
const cacheViewStore = useCacheViewStore();
dayjs.locale('zh-cn');
const userStore = useUserStore()
// 获取用户信息
const getUserInfo = () => {
  $loginUser().then((res: any) => {
    userStore.setUserInfo(res?.data?.user || {});
  })
}

watch(() => userStore.token, (token) => {
  if (token) {
    getUserInfo();
  }
}, {
  immediate: true,
  deep: true,
})
</script>
<style lang="less">
#app {
  width: 100%;
  height: 100%;
  font-size: @font-size-base;
  color: @text-color;
  overflow-y: auto;
  font-family: Microsoft Yahei;
}

strong {
  font-weight: bold !important;
}
</style>
